/* 
 * File:   Event.h
 * Author: Muhammad Anis
 *
 * Created on November 1, 2012, 6:37 AM
 */
#include <stdio.h>
#include <sstream>
#include <stdlib.h>
#include <time.h>
#include "../Point/Point.h"
#include "../BaseElementCal/BaseElementCal.h"
#include <iostream>
#include <vector>


#ifndef EVENT_H
#define	EVENT_H

using namespace std;

class Event : BaseElementCal {
private:
    long entryNo;
    struct tm* dateTime;
    Point<float> position;
    string description;
    int participantCount;
    vector<string> participants;


public:

    void printTime();

    string GetDescription() const {
        return description;
    }

    struct tm* GetDateTime() const {
        return dateTime;
    }

    void SetDateTime(struct tm* _dateTime) {
        //this->dateTime = dateTime;
        dateTime->tm_year =  _dateTime->tm_year;
        dateTime->tm_mon = _dateTime->tm_mon;
        dateTime->tm_mday = _dateTime->tm_mday;
        dateTime->tm_hour = _dateTime->tm_hour;
        dateTime->tm_min = _dateTime->tm_min;
        dateTime->tm_sec = _dateTime->tm_sec;
    }

    void SetDescription(string& description) {
        this->description = description;
    }

    long GetEntryNo() const {
        return entryNo;
    }

    void SetEntryNo(long entryNo) {
        this->entryNo = entryNo;
    }

    int GetParticipantCount() {
        return participantCount;
    }

    void SetParticipantCount(int participantCount) {
        this->participantCount = participantCount;
    }

    void SetParticipants(const vector<string>& _participants) {
        //        this->participants.clear();               
        //        for (int i = 0; i < _participants.size(); ++i) {
        //            this->participants.push_back(_participants[i]);
        //        }
        //        //this->participants.

        //        this->participants.clear();
        //        //this->participants.operator =(_participants);         
        //        for (int i = 0; i < _participants.size(); ++i) {
        //            string s = _participants.at(i);
        //            this->participants.push_back(s);
        //        }
        this->participants = _participants;
    }

    vector<string> GetParticipants() {
        return this->participants;
    }

    Point<float> GetPosition() const {
        return position;
    }

    void SetPosition(Point<float> position) {
        this->position = position;
    }

    Event();
    Event(long entryNo, struct tm* times, Point<float> position, string description, vector<string> participants, short int participantCount);
    Event(const Event&);
    ~Event();

    Event& operator=(const Event&);
    bool operator<(const Event&);
    bool operator==(const Event&);

    string toString();

    class EventComparator {
    public:

        bool operator()(const Event& e1, const Event& e2) {
            //time_t time1 = e1.GetDateTime();
            //time_t time2 = e2.GetDateTime();
            //struct tm * tm1 = localtime(&time1);
            //struct tm * tm2 = localtime(&time2);
            struct tm* tm1 = e1.GetDateTime();
            struct tm* tm2 = e2.GetDateTime();
            if (tm1->tm_year < tm2->tm_year) {
                return true;
            } else if (tm1->tm_mon < tm2->tm_mon) {
                return true;
            } else if (tm1->tm_mday < tm2->tm_mday) {
                return true;
            } else if (tm1->tm_hour < tm2->tm_hour) {
                return true;
            } else if (tm1->tm_min < tm2->tm_min) {
                return true;
            } else if (tm1->tm_sec < tm2->tm_sec) {
                return true;
            }
            return false;
        }
    };
};

#endif	/* EVENT_H */

